﻿using DreamCMS.BLL;
using DreamCMS.Entity;
using DreamCMS.Web.Admin;
using DreamCMS.WebCore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web.Admin.CatMgr
{
    public partial class AddCat : AdminPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }


        protected void Add_Click(object sender, EventArgs e)
        {
            long newSort = StringHelper.StrToInt64(Request["catSort"], 0);
            string newName = Request["catName"];
            string des = Request["catDescription"];
            string slug = Request["catSlug"];
            if (!string.IsNullOrEmpty(newName))
            {
                if (newSort == 0)
                {
                    newSort = 1000;
                }
                CategoryInfo cat = new CategoryInfo();
                cat.Name = newName; cat.Diplayorder = newSort; cat.Description = des; cat.Slug = slug;
                if (CategoryManager.InsertCategory(cat) > 0)
                {
                    ClientScript.RegisterStartupScript(GetType(), "successAdd", "<script>alert('添加成功');</script>");
                }
                else
                {
                    ClientScript.RegisterStartupScript(GetType(), "errir", "<script>alert('添加失败');</script>");
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "errir", "<script>alert('添加失败');</script>");
            }
        }
    }
}